package self;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

// AWT / Swing
public class TuXing {
    public static void main(String[] args) {
//        FirstFrame firstFrame = new FirstFrame();
//        firstFrame.showFrame();
//        FrameaddedPanel frameaddedPanel = new FrameaddedPanel();
//        frameaddedPanel.showPanel();
    }
}

class FirstFrame extends Frame{
    public FirstFrame(){};
    public FirstFrame(String string){
        super(string);
    }
    public void showFrame(){
        FirstFrame firstFrame = new FirstFrame("第一个Frame");
        firstFrame.setSize(300,200);
        firstFrame.setBackground(Color.PINK);
        firstFrame.setVisible(true);
        firstFrame.addWindowListener(firstFrame.new Mywindowadapter());
    }
    class Mywindowadapter extends WindowAdapter {
        public void windowClosing(WindowEvent we){
            System.exit(0);
        }
    }

}

class FrameaddedPanel extends Frame{
    public FrameaddedPanel(){};
    public FrameaddedPanel(String string){
        super(string);
    }
    public void showPanel(){
        FrameaddedPanel frameaddedPanel = new FrameaddedPanel("在Frame中添加Panel");
        Panel panel = new Panel();
        frameaddedPanel.setSize(400,300);
        frameaddedPanel.setBackground(Color.PINK);
        frameaddedPanel.setLayout(null);
        panel.setSize(200,200);
        panel.setBackground(Color.CYAN);
        frameaddedPanel.add(panel);
        frameaddedPanel.setVisible(true);
        frameaddedPanel.addWindowListener(frameaddedPanel.new Mywindowadapter());
    }
    class Mywindowadapter extends WindowAdapter {
        public void windowClosing(WindowEvent we){
            System.exit(0);
        }
    }
}

//class FlowLayoutDemo{
//    public FlowLayoutDemo(){
//        b1 = new Button("继续");
//        b2 = new Button("取消");
//        b3 = new Button("确定");
//    }
//    public void show(){
////        FlowLayoutDemo f1 = new FlowLayoutDemo();
//        f = new Frame("FlowLayout顺序布局");
//
//
//    }
//}
